using Microsoft.AspNetCore.Mvc;
using JTZY.Model.Pay.Dto;
using JTZY.Model.Pay;
using JTZY.Service.Pay.IPayService;
using JTZY.Admin.WebApi.Filters;

//创建时间：2025-02-23
namespace JTZY.Admin.WebApi.Controllers.Pay
{
    /// <summary>
    /// 微信支付配置
    /// </summary>
    [Verify]
    [Route("pay/Corecmswechatpayconfig")]
    public class CorecmswechatpayconfigController : BaseController
    {
        /// <summary>
        /// 微信支付配置接口
        /// </summary>
        private readonly ICorecmswechatpayconfigService _CorecmswechatpayconfigService;

        public CorecmswechatpayconfigController(ICorecmswechatpayconfigService CorecmswechatpayconfigService)
        {
            _CorecmswechatpayconfigService = CorecmswechatpayconfigService;
        }

        /// <summary>
        /// 查询微信支付配置列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "corecmswechatpayconfig:list")]
        public IActionResult QueryCorecmswechatpayconfig([FromQuery] CorecmswechatpayconfigQueryDto parm)
        {
            var response = _CorecmswechatpayconfigService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询微信支付配置详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "corecmswechatpayconfig:query")]
        public IActionResult GetCorecmswechatpayconfig(int Id)
        {
            var response = _CorecmswechatpayconfigService.GetInfo(Id);
            
            var info = response.Adapt<CorecmswechatpayconfigDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加微信支付配置
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "corecmswechatpayconfig:add")]
        [Log(Title = "微信支付配置", BusinessType = BusinessType.INSERT)]
        public IActionResult AddCorecmswechatpayconfig([FromBody] CorecmswechatpayconfigDto parm)
        {
            var modal = parm.Adapt<Corecmswechatpayconfig>().ToCreate(HttpContext);

            var response = _CorecmswechatpayconfigService.AddCorecmswechatpayconfig(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新微信支付配置
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "corecmswechatpayconfig:edit")]
        [Log(Title = "微信支付配置", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateCorecmswechatpayconfig([FromBody] CorecmswechatpayconfigDto parm)
        {
            var modal = parm.Adapt<Corecmswechatpayconfig>().ToUpdate(HttpContext);
            var response = _CorecmswechatpayconfigService.UpdateCorecmswechatpayconfig(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除微信支付配置
        /// </summary>
        /// <returns></returns>
        [HttpPost("delete/{ids}")]
        [ActionPermissionFilter(Permission = "corecmswechatpayconfig:delete")]
        [Log(Title = "微信支付配置", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteCorecmswechatpayconfig([FromRoute]string ids)
        {
            var idArr = Tools.SplitAndConvert<int>(ids);

            return ToResponse(_CorecmswechatpayconfigService.Delete(idArr));
        }

    }
}